package vn.wallet.app.managedBean;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.Queue;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

import vn.wallet.app.domain.User;
import vn.wallet.app.task.BackgroundTask;

@ManagedBean(name = "siteConfig", eager = true)
@ApplicationScoped
public class SiteConfigBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Default site title
	 */
	private String siteTitle = "leu leu";

	/**
	 * Title prefix, all child must have this config
	 */
	private final String TITLE_PREFIX = "Wallet King - ";

	/**
	 * Logined user
	 */
	private User currentUser;

	/**
	 * Queue Task for ensure only concurrence task
	 */
	private final Queue<BackgroundTask> queue;

	public SiteConfigBean() {
		queue = new LinkedList<BackgroundTask>();
	}

	public String getSiteTitle() {
		return siteTitle;
	}

	public void setSiteTitle(String siteTitle) {
		siteTitle = TITLE_PREFIX + siteTitle;
		this.siteTitle = siteTitle;
	}

	public User getCurrentUser() {
		return currentUser;
	}

	public void setCurrentUser(User currentUser) {
		this.currentUser = currentUser;
	}

	public Queue<BackgroundTask> getQueue() {
		return queue;
	}

	public void addNewTask(BackgroundTask configuredTask) {
		// TODO Auto-generated method stub
	}

	class ExecuteTask implements Runnable {

		@Override
		public void run() {

		}

	}
}
